package com.yuxi.controller;

import com.yuxi.model.TTest;
import com.yuxi.service.TTestService;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * Created by yuxi on 16/11/5.
 */
@RestController
public class TTestController {

    @Autowired
    private TTestService tTestServcie;

    @ApiOperation("test")
    @ApiResponses({
            @ApiResponse(code = 404, message = "请求路径没有或页面跳转路径不对"),
            @ApiResponse(code = 500, message = "内部服务错误")
    })
    @RequestMapping(value = "/getTest", method = RequestMethod.GET)
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "id", dataType = "int", required = true, value = "id", defaultValue = "1")
    })
    public Object getTest(Integer id) {
        List<TTest> list = tTestServcie.getTest(id);
        return list;
    }

    @ApiOperation("新增用户")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "name", dataType = "String", required = true, value = "用户名", defaultValue = "yuxi")
    })
    @ApiResponses({
            @ApiResponse(code = 404, message = "请求路径没有或页面跳转路径不对"),
            @ApiResponse(code = 500, message = "内部服务错误")
    })
    @RequestMapping(value = "/insert", method = RequestMethod.POST)
    public boolean delete(@RequestParam("name")  String name) {
        return tTestServcie.insert(name);
    }


}
